<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>绿地养护</title>
	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../../css/globle.css" />
	<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
	<link rel="stylesheet" type="text/css" href="../../css/common.css" />
	<style>
		body {}

		span {
			margin: 10px;
		}

		.Tabl {
			height: 50px;
			width: 88%;
			font-size: 14px;
			font-weight: bold;
			text-align: left;
			margin-left: 6%;
		}

		.Td1 {
			color: #B8B8B8;
			width: 65px;
			font-size: 15px;
		}

		.Td2 {
			color: rgb(85, 85, 85);
			font-size: 18px;
			text-align: left;
			width: 80px;

		}

		.Td3 {
			background-color: #1ABC9C;
			text-align: center;
			width: 50%;
		}

		.Hr {
			height: 1px;
			width: 96%;
			background-color: #D8D8D8;
			margin-left: 2%;
		}

		.Butt {
			border: 1px solid #B8B8B8;
			border-radius: 20px;
			color: #FFFFFF;
			height: 17px;
			width: 17px;
			outline: none;
		}

		.TabImg {
			height: 150px;
			width: 96%;
			margin-left: 2%;
			border: 10px solid #D8D8D8;
		}

		.TdImg1 {
			height: 110px;
			width: 90px;
		}

		.TdImg2 {
			height: 110px;
			width: 90px;
		}

		.ButAdd {
			height: 110px;
			width: 100px;
			font-size: 100px;
			color: #FFFFFF;
			background-color: #B8B8B8;
		}

		.Tabl {
			height: 50px;
			width: 88%;
			font-size: 14px;

			text-align: left;
			margin-left: 6%;
		}

		.ButL {
			height: 40px;
			width: 100%;
			background-color: #D0D0D0;
			position: fixed;
			bottom: 0;
		}

		.Td3 {
			text-align: center;
			width: 50%;
		}

		select {
			appearance: none;
			-moz-appearance: none;
			-webkit-appearance: none;
			border: none;
			background: none;
		}

		input::-webkit-input-placeholder {
			/* placeholder颜色  */
			color: #aab2bd;
			/* placeholder字体大小  */
			font-size: 12px;
			/* placeholder位置  */
			/* text-align: right; */
		}

		textarea::-webkit-input-placeholder {
			/* placeholder颜色  */
			color: #aab2bd;
			/* placeholder字体大小  */
			font-size: 12px;
			/* placeholder位置  */
			text-align: center;
		}
	</style>
</head>

<body>
	<button style="background-color: #F2F2F2;height: 40px;width: 100%;font-size: 18px;">基本信息</button>
	<table class="Tabl">
		<input style="width: 80%;" type="hidden" id="id" />
		<tr>
			<td class="Td1">绿地名称</td>
			<td class="Td2" id="qqq">
				<select id="codeGreenlandid">
					<option value=""> -请选择- </option>

					<option v-for="todo in todos" :value="todo.id"> {{todo.greedLandAdministrator.name}} </option>
				</select><!-- <input type="text" value="洛带古镇客栈区" /> -->
			</td>
		</tr>
	</table>
	<hr class="Hr" />
	<table class="Tabl">
		<tr>
			<td class="Td1">维修内容</td>
			<td class="Td2" id="qqq1">
				<select id="maintenanceContent">
					<option value=""> -请选择- </option>
					<option v-for="todoss in todos" :value="todoss.id"> {{todoss.name}} </option>
				</select></td>

			<td class="Td1">工人数量</td>
			<td class="Td2">
				<input type="number" style="width: 80%;" id="peopleNum" placeholder="工人数量" />
			</td>
		</tr>
	</table>
	<hr class="Hr" />
	<table class="Tabl">
		<tr>
			<td class="Td1">工 &nbsp;作 &nbsp;量</td>
			<td class="Td2">
				<input style="width: 80%;" type="text" id="maintenanceNum" placeholder="工作量" />
			</td>
			<td class="Td1">机械类型</td>
			<td class="Td2" id="qqq2">
				<select id="mechanicalType">
					<option id="mechanicalType" value="0">-请选择-</option>

					<option v-for="device in todos" :value="device.dName">{{device.dName}}</option>
					<!--	<option value="平板振动机">平板振动机</option>
					<option value="切割机">切割机</option>
					<option value="挖坑机">挖坑机</option>
					<option value="抽水机">抽水机</option>
					<option value="割草机">割草机</option>
					<option value="打药机">打药机</option>-->
			</td>
		</tr>
	</table>
	<hr class="Hr" />
	<table class="Tabl">
		<tr>
			<td class="Td1">工具数量</td>
			<td class="Td2">
				<input type="number" style="width: 80%;" id="manHour" placeholder="工具数量..." />
			</td>
			<td class="Td1">机械名称</td>
			<td class="Td2">
				<select id="mechanicalName">
					<option value="0">-请选择-</option>
					<option value="拖拉机">拖拉机</option>
					<option value="挖掘机">挖掘机</option>
					<option value="铲车">铲车</option>
				</select>
			</td>

		</tr>
	</table>
	<hr class="Hr" />
	<table class="Tabl">
		<tr>
			<td class="Td1">负 &nbsp;责&nbsp; 人</td>
			<td class="Td2">
				<input id="fzpeople" placeholder="负责人..." />
			</td>
		</tr>
	</table>

	<button style="background-color: #F2F2F2;height: 40px;width: 100%;font-size: 18px;">现场图片</button>
	<div style="padding: 5px;">
		<div id="goodsUpload1"></div>
		<div style="width: 80%;position: absolute;right: 10%;left:10%;top: 20%;z-index: 1000000;text-align: center;"
			id="bigImage"></div>
	</div>

	<div style="padding: 10px;">
		<ul class="upload-ul clearfix">
			<li class="upload-pick">
				<div class="webuploader-container clearfix" id="goodsUpload"></div>
			</li>
		</ul>
	</div>
	<hr class="Hr" />
	<table class="Tabl">
		<tr>
			<td class="Td1">补充信息</td>
		</tr>
	</table>
	<hr class="Hr" />
	<table class="TabL">
		<tr>
			<td> <textarea rows="4" style="margin-top: 10px;" cols="35" id="remark" placeholder="填写你的其他内容描述！"></textarea></td>
		</tr>
	</table>
	<table class="ButL">
		<tr>
			<td class="Td3">
				<div style="color:#FFFFFF" onclick="sublmt()">
					完成
				</div>
			</td>
		</tr>
	</table>
</body>
<script src="../../script/webuploader.min.js"></script>
<script src="../../script/jquery.js"></script>
<script src="../../script/diyUpload.js"></script>
<script src="../../script/vue.js"></script>
<script src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript">
	var $tgaUpload = $('#goodsUpload').diyUpload({
		url: BaseServiceUrl + "mobile/mainten/uploudfile.json",

		success: function (data) {
			//alert(JSON.stringify(data))
		},
		error: function (err) {
			alert(JSON.stringify(err))
		},
		buttonText: '',
		accept: {
			title: "Images",
			extensions: 'gif,jpg,jpeg,bmp,png'
		},
		thumb: {
			width: 120,
			height: 90,
			quality: 100,
			allowMagnify: true,
			crop: true,
			type: "image/jpeg"
		}
	});
	$tgaUpload.options.formData.dids = null;
	//$tgaUpload.options.formData.did1=null;


	apiready = function () {


		var userid = $api.getStorage('userSession').data.id;
		//用户id
		//片区id
		var reg = $api.getStorage("userSession");
		var sids = reg.data.sysRole.sysRoleCode;
		var role = sids.role_number;
		var areaid = null;
		if (role != "construction") {
			areaid = $api.getStorage('selectpor').id
			var projectName = $api.getStorage('selectpor').projectName;
			$("#projectName").html(projectName);
		} else {
			areaid = reg.data.areaid;
		}
		//项目id
		var proid = $api.getStorage('userSession').data.proId;
		//企业id
		var enterpriseid = $api.getStorage('userSession').data.enterprise.id;
		//绿地id
		var greenlandid = $api.getStorage('userSession').data.greenlandid;

		//获取施工队的绿地
		var app = new Vue({
			el: '#qqq',
			data: {
				todos: []
			},
			created: function () {
				$.ajax({
					type: "post",
					//async : false, //同步执行
					url: BaseServiceUrl + "mobile/mainten/getGreedLandNamex.json",
					data: {
						greenlandid: greenlandid,
					},
					dataType: "json", //返回数据形式为json
					success: function (result) {
						for (var i = 0; i < result.data.length; i++) {
							app.todos.push(result.data[i])
						}
					}
				});
			}
		})
		//获取养护内容
		var app1 = new Vue({
			el: '#qqq1',
			data: {
				todos: []
			},
			created: function () {
				$.ajax({
					type: "post",
					//async : false, //同步执行
					url: BaseServiceUrl + "mobile/mainten/getMaintenType.json",
					data: {
						type: 3,
						enterpriseid: enterpriseid

					},
					dataType: "json", //返回数据形式为json
					success: function (result) {
						for (var i = 0; i < result.data.length; i++) {
							app1.todos.push(result.data[i])
						}
					}
				});
			}
		})

		//获取机械类型
		var app2 = new Vue({
			el: '#qqq2',
			data: {
				todos: []
			},
			created: function () {
				$.ajax({
					type: "post",
					//async : false, //同步执行
					url: BaseServiceUrl + "mobile/device/find.json",
					data: {},
					dataType: "json", //返回数据形式为json
					success: function (result) {

						for (var i = 0; i < result.data.length; i++) {
							app2.todos.push(result.data[i])
						}
					}
				});
			}
		})


		var id = api.pageParam.id;
		//获取绿地养护
		$.ajax({
			type: "post",
			//async : false, //同步执行
			url: BaseServiceUrl + "mobile/mainten/view.json",
			data: {
				id: id
			},
			dataType: "json", //返回数据形式为json
			success: function (result) {
				var data = result.data
				var ldname = data.greedLand.id;
				var maintenanceContent = data.maintenType.id
				$("#codeGreenlandid").find("option[value=" + ldname + "]").attr('selected', 'selected');
				$("#maintenanceContent").find("option[value=" + maintenanceContent + "]").attr('selected', 'selected')
				$("#maintenanceNum").val(data.maintenanceNum);
				$("#peopleNum").val(data.peopleNum);
				$("#manHour").val(data.manHour);
				$("#mechanicalType").val(data.mechanicalType);
				$("#fzpeople").val(data.fzpeople);
				$("#remark").val(data.remark);
				$("#mechanicalName").val(data.mechanicalName);
				$("#id").val(data.id);
				var h = ""
				for (var i = 0; i < result.data.maintenPhotoList.length; i++) {
					h +=
						'<div style=\"margin-left:5px;float:left;margin-top:5px;\"><img width="130" height="130"  onclick=\'showBig(this)\'  src="' +
						BaseServiceUrl + result.data.maintenPhotoList[i].photo + '"/><\/div>'
				}
				$("#goodsUpload1").append(h);
			}
		});


	};


	//上传信息
	function sublmt() {
		var codeGreenlandid = $("#codeGreenlandid").val();
		if (codeGreenlandid == null || codeGreenlandid == '') {
			alert("请输入绿地名称");
			return false;
		}
		var maintenanceNum = $("#maintenanceNum").val();
		/* if (maintenanceNum == null || maintenanceNum == '') {
			alert("请输入工作量");
			return false;
		} */
		var peopleNum = $("#peopleNum").val();
		/* 	if (peopleNum == null || peopleNum == '') {
				alert("请输入工人数量");
				return false;
			} */
		var maintenanceContent = $("#maintenanceContent").val();
		if (maintenanceContent == null || maintenanceContent == '') {
			alert("请选择维修内容");
			return false;
		}
		var fzpeople = $("#fzpeople").val();
		/* 	if (fzpeople == null || fzpeople == '') {
				alert("请输入负责人");
				return false;
			} */
		var mechanicalType = $("#mechanicalType").val();
		/* 	if (mechanicalType == null || mechanicalType == '') {
				alert("请选择机械类型");
				return false;
			} */
		var mechanicalName = $("#mechanicalName").val();
		/* 	if (mechanicalName == null || mechanicalName == '') {
				alert("请选择机械名称");
				return false;
			} */

		var manHour = $("#manHour").val();
		/* 	if (manHour == null || manHour == '') {
				alert("请输入工具数量");
				return false;
			} */

		//用户id
		//片区id
		var reg = $api.getStorage("userSession");
		var sids = reg.data.sysRole.sysRoleCode;
		var role = sids.role_number;
		var areaid = null;
		if (role != "construction") {
			areaid = $api.getStorage('selectpor').id
			var projectName = $api.getStorage('selectpor').projectName;
			$("#projectName").html(projectName);
		} else {
			areaid = reg.data.areaid;
		}
		//项目id
		var proid = $api.getStorage('userSession').data.proId;
		//企业id
		var enterpriseid = $api.getStorage('userSession').data.enterprise.id;
		//队伍id
		var teamid = $api.getStorage('userSession').data.team_id;
		var userid = $api.getStorage('userSession').data.id
		var remark = $("#remark").val();
		$.ajax({
			url: BaseServiceUrl + "mobile/mainten/lvdisave.json",
			type: "POST",
			data: {
				'type': 3,
				'greedLand': codeGreenlandid,
				'maintenanceNum': maintenanceNum,
				'peopleNum': peopleNum,
				'maintenanceContent': maintenanceContent,
				'mechanicalType': mechanicalType,
				'manHour': manHour,
				'remark': remark,
				'fzpeople': fzpeople,
				'proid': proid,
				'areaid': areaid,
				'userid': userid,
				'enterpriseid': enterpriseid,
				'teamid': teamid,
				'mechanicalName': mechanicalName,
				'id': $("#id").val()

			},
			dataType: 'json',
			success: function (ret) {
				//alert(JSON.stringify(ret));
				$tgaUpload.options.formData.dids = ret.data;

				$tgaUpload.upload();

				if (ret.code == 0) {
					api.showProgress({
						//打开开关
						title: "提交中...",
						text: "",
					});
					setTimeout(function () {
						api.closeWin();
					}, 5000);
				}




			}
		});
	}

	function showBig(t) {
		document.getElementById("bigImage").innerHTML = "<img src='" + t.src +
			"' onclick='closeBig(this)'  width='100%' style='border:3px solid #4f4f4f;'/>";
	}

	function closeBig(t) {
		document.getElementById("bigImage").innerHTML = "";
	}
</script>

</html>